package com.alog.common.code;

public class SyncTest {
    public static void main(String[] args) {
        for(int i = 0; i < 10; i++){
            new Thread(() ->{
                while (true){
                    SyncQueue.getInstance().poll();
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            } , "consumer" + i).start();
            new Thread(() -> {
                while (true){
                    SyncQueue.getInstance().add();
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }, "productor" + i).start();
        }
    }
}
